package cn.jingzhuan.fm.mvp.presenter

import cn.jingzhuan.fm.mvp.contract.FMAudioCommentSendContract
import cn.jingzhuan.fm.mvp.model.FMAudioCommentSendModel
import io.reactivex.android.schedulers.AndroidSchedulers
import javax.inject.Inject

/**
 * Created by Administrator on 2018/5/11.
 */
class FMAudioCommentSendPresenter  @Inject constructor(
        private val view: FMAudioCommentSendContract.View,
        private val model: FMAudioCommentSendModel): FMAudioCommentSendContract.Presenter{

    override fun sendComment(audioId: String, content: String) {
        model.sendComment(audioId,content)
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe({
                    if (it.isSuccess) {
                        view.onSendCommentOver(true, it.msg)
                    } else {
                        view.onSendCommentOver(false, it.msg)
                    }
                }) {
                    view.onSendCommentOver(false,"发送失败，请稍后重试！")
                }
    }
}